﻿@{
    Layout = "~/Shared/Layouts/_AdminLayout.cshtml";
    Page.Title = "Препорачани производи";
    
    var featuredProduct = "";
    
    var db = Database.Open("VirtualeShop");
    
    if(IsPost)
    {
        featuredProduct = Request["featuredProduct"];
        var sqlUpdate = "UPDATE Settings SET featuredProduct = @0";
        db.Execute(sqlUpdate, featuredProduct);
        
        Response.Redirect("~/Admin");
    }
    
    var sqlCommand = "SELECT featuredProduct FROM Settings";
    featuredProduct = db.QuerySingle(sqlCommand).featuredProduct.ToString();
}

<h1>Препорачани производи</h1>

<form action="Featured" method="post">
    <p>
        Препорачани производи:
        @Products.ProductsDropDownList("featuredProduct", featuredProduct)
        <input type="submit" value="Зачувај" />
    </p>
</form>